package com.mzwise.tunnel.wx.miniapp.api.impl;

import com.mzwise.tunnel.wx.miniapp.api.WxMaImmediateDeliveryService;
import cn.binarywang.wx.miniapp.api.WxMaService;
import com.mzwise.tunnel.wx.miniapp.immediateDelivery.request.WxMaImmediateDeliveryAddOrderRequest;
import com.mzwise.tunnel.wx.miniapp.immediateDelivery.result.WxMaImmediateDeliveryOrderInfoResult;
import me.chanjar.weixin.common.error.WxErrorException;

/**
 * @author wmf</a>
 * @since 2020-04-02
 */
public class WxMaImmediateDeliveryServiceImpl implements WxMaImmediateDeliveryService {

  private WxMaService wxMaService;


  @Override
  public WxMaImmediateDeliveryOrderInfoResult addOrder(WxMaImmediateDeliveryAddOrderRequest wxMaExpressAddOrderRequest) throws WxErrorException {
    String responseContent = this.wxMaService.post(ADD_ORDER_URL, wxMaExpressAddOrderRequest.toJson());
    return WxMaImmediateDeliveryOrderInfoResult.fromJson(responseContent);
  }

  public WxMaImmediateDeliveryServiceImpl(WxMaService wxMaService) {
    this.wxMaService = wxMaService;
  }
}
